#include "datafilereader.h"

dataFileReader::dataFileReader()
{

}

void dataFileReader::SetFileName(const String sFileName)
{
    sName = QString::fromStdString(sFileName);
}

void dataFileReader::ReadFile(void)
{
    QFile file(sName);
    if  (!file.open(QFile::ReadOnly | QFile::Text))
    {
        return;
    }
    pFile = file.map(0,file.size());
    if (pFile)
    {
        String sfile((char*)pFile);
        POS pos = SetFileHeader(sfile);

        GetAllPos(sfile, pos);

        std::thread t1 = ThreadMeshvertex(sfile, allPos.vertexPos.start);
        std::thread t2 = ThreadTriIndex(sfile, allPos.trindexPos.start);
        std::thread t3 = ThreadFirstFieldVertex(sfile, allPos.vfieldatazonePos[0]->start);
        t1.join();
        t2.join();
        t3.join();
//n=30
        UINT n = allPos.vfieldatazonePos.size() / 4;
        qDebug()<<n;

        for (UINT i = 0; i < n - 1; i++)
        {
            std::thread t4 = ThreadOtherFieldVerteies(sfile, allPos.vfieldatazonePos[4 * i + 1]->start);
            std::thread t5 = ThreadOtherFieldVerteies(sfile, allPos.vfieldatazonePos[4 * i + 2]->start);
            std::thread t6 = ThreadOtherFieldVerteies(sfile, allPos.vfieldatazonePos[4 * i + 3]->start);
            std::thread t7 = ThreadOtherFieldVerteies(sfile, allPos.vfieldatazonePos[4 * i + 4]->start);

            t4.join();
            t5.join();
            t6.join();
            t7.join();
        }

        for (UINT i = 4 * (n - 1) + 1; i < allPos.vfieldatazonePos.size(); i++)
        {
            std::thread t8 = ThreadOtherFieldVerteies(sfile, allPos.vfieldatazonePos[i]->start);
            t8.join();
        }

    }

    //排序,因为多线程读取之后时间序列打乱
    alldata.ldata.sort(
        [](PZoneData pdata1, PZoneData pdata2)
        {
            if (pdata1->zhZoneHeader.sTime.compare(pdata2->zhZoneHeader.sTime) < 0)
            {
                return(true);
            }
            return(false);
        });

    if(allPos.vfieldatazonePos.size() == 120 &&
            alldata.ldata.size() == 120)
        qDebug()<<"数据读取正确";
    else
    {
        qDebug()<<"数据读取不正确"<<allPos.vfieldatazonePos.size()<<alldata.ldata.size();
    }
    file.unmap(pFile);
    file.close();

}


void dataFileReader::GetVertex(osg::ref_ptr<osg::Vec3Array> vertex)
{
    minDepth = alldata.vMeshVertex[2] / -1000.0;
    maxDepth = alldata.vMeshVertex[2] / -1000.0;
    float temp = 0.0;

    for(int i=0;i<alldata.vMeshVertex.size() / 3;i++)
    {
       temp = alldata.vMeshVertex[3*i+2] / -1000.0;
       if(temp - maxDepth > 0.00001)
           maxDepth = temp;
       if(minDepth - temp > 0.00001)
           minDepth = temp;
       vertex->push_back(osg::Vec3(
                              alldata.vMeshVertex[3*i],   //x
                              alldata.vMeshVertex[3*i+2] / -1000.0, //y
                              alldata.vMeshVertex[3*i+1]  //z
                              ));

    }

}

void dataFileReader::GetColor(osg::ref_ptr<osg::Vec4Array> color)
{
    //形成色谱 -红-黄-绿-青-蓝
    float delta = (maxDepth - minDepth) / 4;
    //色谱划分
    float clrLevel[5];
    for(int i=0;i<5;i++)
    {
        clrLevel[i] = minDepth + i * delta;
    }

    float temp = 0.0;
    osg::Vec4 clr;

    for(int i=0;i<alldata.vMeshVertex.size() / 3;i++)
    {
        temp = alldata.vMeshVertex[3*i+2] / -1000.0;

        if(temp >= clrLevel[0] && temp < clrLevel[1])
        {//红-黄
           clr.set(1.0,
                    (temp - clrLevel[0]) / delta,
                    0.0,
                    1.0);
           color->push_back(clr);
        }
        else if(temp >= clrLevel[1] && temp < clrLevel[2])
        {//黄-绿
           clr.set(1.0 - (temp - clrLevel[1]) / delta,
                   1.0,
                    0.0,
                    0.0);
           color->push_back(clr);
        }
        else if(temp >= clrLevel[2] && temp < clrLevel[3])
        {//绿-青
           clr.set(0.0,
                   1.0,
                   (temp - clrLevel[2]) / delta,
                   1.0);
           color->push_back(clr);
        }
        else if(temp >= clrLevel[3] && temp <= clrLevel[4])
        {//青-蓝
           clr.set(0.0,
                   1.0 - (temp - clrLevel[3]) / delta,
                   1.0,
                   1.0);

           color->push_back(clr);
        }
    }

}


void dataFileReader::GetIndice(osg::ref_ptr<osg::DrawElementsUInt> indice)
{
    indice->resize(alldata.vTriIndex.size());
    std::copy(alldata.vTriIndex.begin(),alldata.vTriIndex.end(),
              indice->begin());
}

///////////////////////////////////////////////////////////
//获得文件头
POS dataFileReader::SetFileHeader(String& sfile)
{
    //标题行
    POS pos = SetTitle(sfile, alldata.Header.sTitle);
    //变量行
    pos = SetVar(sfile, pos, alldata.Header.sVar);
    //时间行
    PZoneData pdata = std::make_shared<ZoneData>();
    pos = SetDateNE(sfile, pos, pdata->zhZoneHeader.sTime,
                    pdata->zhZoneHeader.nVertex, pdata->zhZoneHeader.nElement);
    pos = SetZoneType(sfile, pos, pdata->zhZoneHeader.ztZoneType,
                      pdata->zhZoneHeader.sPack);
    pos = SetVarLocation(sfile, pos, pdata->zhZoneHeader.sVarLoc);

    alldata.ldata.push_back(pdata);

    return(pos + 1);
}

/////////////////////////////////////////////////////////////
//以下内部函数
//由string实现
POS dataFileReader::SetTitle(String& sSour, String& stitle)
{
    POS posEnd, pos2, pos3;
    posEnd = sSour.find("\n");
    pos2 = sSour.find("\"");
    pos3 = sSour.find("\"", pos2 + 1);
    stitle = sSour.substr(pos2 + 1, pos3 - pos2 - 1);
    return(posEnd + 1);
}
POS dataFileReader::SetVar(String& sSour, POS pos, String& svar)
{
    POS posEnd, pos1;
    posEnd = sSour.find("\n", pos);
    pos1 = sSour.find("=", pos);
    svar = sSour.substr(pos1 + 1, posEnd - pos1 - 2);
    return(posEnd + 1);
}
POS dataFileReader::SetDate(String& sSour, POS pos, String& sDate)
{
    POS posEnd, pos1, pos2;
    posEnd = sSour.find(",", pos);
    pos1 = sSour.find("\"", pos);
    pos2 = sSour.find("\"", pos1 + 1);
    sDate = sSour.substr(pos1 + 1, pos2 - pos1 - 1);

    return(posEnd + 1);

}
POS dataFileReader::SetN(String& sSour, POS pos, int& n)
{
    POS posEnd, pos1;
    posEnd = sSour.find(",", pos);
    pos1 = sSour.find("=", pos);
    n = atoi(sSour.substr(pos1 + 1, posEnd - pos1 - 1).c_str());
    return(posEnd + 1);


}
POS dataFileReader::SetE(String& sSour, POS pos, int& e)
{
    POS posEnd, pos1;
    posEnd = sSour.find("\n", pos);
    pos1 = sSour.find("=", pos);
    e = atoi(sSour.substr(pos1 + 1, posEnd - pos1 - 1).c_str());
    return(posEnd + 1);

}
POS dataFileReader::SetDateNE(String& sSour, POS pos, String& sData, int& n, int& e)
{
    POS posEnd;
    posEnd = SetDate(sSour, pos, sData);
    posEnd = SetN(sSour, posEnd + 1, n);
    posEnd = SetE(sSour, posEnd + 1, e);

    posEnd = sSour.find("\n", pos);

    return(posEnd + 1);

}
POS dataFileReader::SetZoneType(String& sSour, POS pos, ZoneType& type, String& sPack)
{
    POS posEnd, pos1, pos2;
    pos1 = sSour.find("=", pos);
    pos2 = sSour.find(",", pos1 + 1);
    String s = sSour.substr(pos1 + 1, pos2 - pos1 - 1);
    if (s == "FEquadrilateral")
    {
        type = FEquadrilateral;
    }
    posEnd = sSour.find("\n", pos);
    pos1 = sSour.find("=", pos2 + 1);
    sPack = sSour.substr(pos1 + 1, posEnd - pos1 - 2);
    return(posEnd + 1);
}
POS dataFileReader::SetVarLocation(String& sSour, POS pos, String& sLoc)
{
    POS posEnd, pos1, pos2;
    pos1 = sSour.find("(", pos);
    pos2 = sSour.find(")", pos1 + 1);
    sLoc = sSour.substr(pos1 + 1, pos2 - pos1 - 1);
    posEnd = sSour.find("\n", pos);
    return(posEnd + 1);
}

/////////////////////////////////////////////////////////////
//多线程读函数 前提是文件头已经读完
void dataFileReader::GetAllPos(String& sSour, POS pos)
{
    //行数
    int nLine = alldata.ldata.front()->zhZoneHeader.nVertex / 10;
    POS pos1;
    pos1 = pos;
    //坐标区
    for (int j = 0; j < 3; j++)
    {
        for (int i = 0; i < nLine + 1; i++)
        {
            pos1 = sSour.find("\n", pos1 + 1);
        }
    }

    allPos.vertexPos.start = pos;
    allPos.vertexPos.end = pos1;
    //第一个field data 区
    PFieldDataZonePos pPos = std::make_shared<FieldDataZonePos>();
    pPos->start = pos1;
    nLine = alldata.ldata.front()->zhZoneHeader.nElement / 10;
    for (int j = 0; j < 3; j++)
    {
        for (int i = 0; i < nLine + 1; i++)
        {
            pos1 = sSour.find("\n", pos1 + 1);
        }
    }
    pPos->end = pos1;

    allPos.vfieldatazonePos.push_back(pPos);
    //索引
    nLine = alldata.ldata.front()->zhZoneHeader.nElement;
    allPos.trindexPos.start = pos1;

    for (int i = 0; i < nLine; i++)
    {
        pos1 = sSour.find("\n", pos1 + 1);
    }
    //以后的field data 区
    nLine = alldata.ldata.front()->zhZoneHeader.nElement / 10;
    while (pos1 < sSour.length() - 5)
    {
        pPos = std::make_shared<FieldDataZonePos>();
        pPos->start = pos1;
        //zone 头
        for (int i = 0; i < 4; i++)
        {
            pos1 = sSour.find("\n", pos1 + 1);
        }
        for (int j = 0; j < 3; j++)
        {
            for (int i = 0; i < nLine + 1; i++)
            {
                pos1 = sSour.find("\n", pos1 + 1);
            }
        }
        pPos->end = pos1;

        allPos.vfieldatazonePos.push_back(pPos);
    }
}
void dataFileReader::SetThreadMeshVertex(String& sfile, POS pos)
{
    //行数
    int nLine = alldata.ldata.front()->zhZoneHeader.nVertex / 10;
    //最后剩余
    int nLeft = alldata.ldata.front()->zhZoneHeader.nVertex % 10;
    //分配内存
    alldata.vMeshVertex.resize(alldata.ldata.front()->zhZoneHeader.nVertex * 3);

    //分割字符串中间变量
    POS pos1, pos2;
    String stemp;
    char ctemp[200] = "";
    char* p1 = nullptr;
    char* token = nullptr;
    pos1 = pos + 1;
    //X
    for (int i = 0; i < nLine; i++)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j)
        {
            alldata.vMeshVertex[3 * 10 * i + 3 * j] = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;
    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j)
    {
        alldata.vMeshVertex[3 * 10 * nLine + 3 * j] = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;
    //Y
    for (int i = 0; i < nLine; i++)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j)
        {
            alldata.vMeshVertex[3 * 10 * i + 3 * j + 1] = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;
    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j)
    {
        alldata.vMeshVertex[3 * 10 * nLine + 3 * j + 1] = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;
    //z0
    for (int i = 0; i < nLine; i++)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j)
        {
            alldata.vMeshVertex[3 * 10 * i + 3 * j + 2] = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;
    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j)
    {
        alldata.vMeshVertex[3 * 10 * nLine + 3 * j + 2] = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }

}

std::thread dataFileReader::ThreadMeshvertex(String& sfile, POS& pos)
{
    return std::thread(
        [&]()
    {
        SetThreadMeshVertex(sfile, pos);
    });
}
void dataFileReader::SetThreadTriIndex(String& sfile, POS pos)
{
    //行数
    int nLine = alldata.ldata.front()->zhZoneHeader.nElement;
    //暂存
    UINT temp[4] = { 0 };
    //分配内存
    alldata.vTriIndex.resize(alldata.ldata.front()->zhZoneHeader.nElement * 3);

    POS pos1, pos2;
    String stemp;
    char ctemp[50] = "";
    char* p1 = nullptr;
    char* token = nullptr;
    pos1 = pos + 1;
    for (int i = 0; i < nLine; i++)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 4; ++j)
        {
            temp[j] = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        alldata.vTriIndex[3 * i]		= temp[0] - 1;
        alldata.vTriIndex[3 * i + 1]	= temp[1] - 1;
        alldata.vTriIndex[3 * i + 2]	= temp[2] - 1;

        pos1 = pos2 + 1;

    }

}
std::thread dataFileReader::ThreadTriIndex(String& sfile, POS& pos)
{
    return std::thread(
        [&]()
    {
        SetThreadTriIndex(sfile, pos);
    });
}




void dataFileReader::SetThreadFirstFieldVertex(String& sfile, POS pos)
{
    //行数
    int nLine = alldata.ldata.front()->zhZoneHeader.nElement / 10;
    //最后剩余
    int nLeft = alldata.ldata.front()->zhZoneHeader.nElement % 10;
    //分配内存
    alldata.ldata.front()->vFieldVertex.resize(alldata.ldata.front()->zhZoneHeader.nElement);
    //初始化
    std::generate(alldata.ldata.front()->vFieldVertex.begin(), alldata.ldata.front()->vFieldVertex.end(),
        []()
    {
        return(std::make_shared<FieldVertex>(0.0, 0.0, 0.0));
    }
    );
    auto it = alldata.ldata.front()->vFieldVertex.begin();
    //分割字符串中间变量
    POS pos1, pos2;
    String stemp;
    char ctemp[200] = "";
    char* p1 = nullptr;
    char* token = nullptr;
    pos1 = pos + 1;

    //z
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->Z = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->Z = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;
    //U
    it = alldata.ldata.front()->vFieldVertex.begin();
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->U = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->U = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;

    //V
    it = alldata.ldata.front()->vFieldVertex.begin();
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->V = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->V = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
}
std::thread dataFileReader::ThreadFirstFieldVertex(String& sfile, POS& pos)
{
    return std::thread(
        [&]()
    {
        SetThreadFirstFieldVertex(sfile, pos);
    });
}




void dataFileReader::SetThreadFieldVertex(String& sfile, POS pos)
{
    //行数
    int nLine = alldata.ldata.front()->zhZoneHeader.nElement / 10;
    //最后剩余
    int nLeft = alldata.ldata.front()->zhZoneHeader.nElement % 10;
    //分配内存
    PZoneData pdata = std::make_shared<ZoneData>();
    POS pos1, pos2;
    //zone 头
    pos1 = SetDateNE(sfile, pos + 1, pdata->zhZoneHeader.sTime, pdata->zhZoneHeader.nVertex, pdata->zhZoneHeader.nElement);
    pos1 = SetZoneType(sfile, pos1, pdata->zhZoneHeader.ztZoneType, pdata->zhZoneHeader.sPack);
    pos1 = sfile.find("\n", pos1 + 1);
    pos1 = sfile.find("\n", pos1 + 1);
    //初始化
    pdata->vFieldVertex.resize(alldata.ldata.front()->zhZoneHeader.nElement);
    std::generate(pdata->vFieldVertex.begin(), pdata->vFieldVertex.end(),
        []()
    {
        return(std::make_shared<FieldVertex>(0.0, 0.0, 0.0));
    }
    );
    auto it = pdata->vFieldVertex.begin();
    //分割字符串中间变量
    String stemp;
    char ctemp[200] = "";
    char* p1 = nullptr;
    char* token = nullptr;
    //z
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1 + 1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->Z = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->Z = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;
    //U
    it = pdata->vFieldVertex.begin();
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->U = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->U = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }
    pos1 = pos2 + 1;

    //V
    it = pdata->vFieldVertex.begin();
    for (int i = 0; i < nLine; ++i)
    {
        pos2 = sfile.find("\n", pos1);
        stemp = sfile.substr(pos1, pos2 - pos1 - 1);
        strcpy_s(ctemp, stemp.c_str());
        p1 = strtok_s(ctemp, " \n", &token);
        for (int j = 0; j < 10; ++j, ++it)
        {
            (*it)->V = atof(p1);
            p1 = strtok_s(nullptr, " ", &token);
        }
        pos1 = pos2 + 1;

    }
    //最后一行
    pos2 = sfile.find("\n", pos1);
    stemp = sfile.substr(pos1, pos2 - pos1 - 1);
    strcpy_s(ctemp, stemp.c_str());
    p1 = strtok_s(ctemp, " \n", &token);
    for (int j = 0; j < nLeft; ++j, ++it)
    {
        (*it)->V = atof(p1);
        p1 = strtok_s(nullptr, " ", &token);
    }

    alldata.ldata.push_back(pdata);
}
std::thread dataFileReader::ThreadOtherFieldVerteies(String& sfile, POS& pos)
{
    return std::thread(
        [&]()
    {
        SetThreadFieldVertex(sfile, pos);
    });
}








